package bat.ke.qq.com.core;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 *
 *
 *
 *
 */
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

        // 注册MyFactoryBean
        // class    100 mapper   scan

        // for

        RootBeanDefinition beanDefinition = new RootBeanDefinition(MyFactoryBean.class);
        beanDefinition.getConstructorArgumentValues()
                .addGenericArgumentValue("bat.ke.qq.com.mapper.UserMapper");
        registry.registerBeanDefinition("userMapper",beanDefinition);


        RootBeanDefinition beanDefinition2 = new RootBeanDefinition(MyFactoryBean.class);
        beanDefinition2.getConstructorArgumentValues()
                .addGenericArgumentValue("bat.ke.qq.com.mapper.AccountMapper");
        registry.registerBeanDefinition("accountMapper",beanDefinition2);

    }
}
